package org.zjt.collections;

import com.zaxxer.hikari.util.FastList;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.function.Consumer;

import static java.lang.System.out;

/**
 * @author <a href="juntao.zhang@qq.com">juntao.zhang</a>
 * @Description:
 * @Package org.zjt.collections
 * @date 2018/5/9 10:11
 * @see
 */
@Slf4j
public class FastListTest {

    public static void main(String[] args) {
        FastList fastList =  new FastList(Integer.class);

        List<Integer> list = new ArrayList<>();

        printRT(()->{for (int i = 0; i < 100000; i++) {
            fastList.add(i);
        }},"fastList add ");

        printRT(() -> {
            for (int i = 0; i < 100000; i++)
                list.add(i);
        },"list add ");



        printRT(()->{
            for (int i = 0; i < 10000; i++)
                list.remove(i);
        },"list delete");


        printRT(()->{
            for (int i = 0; i < 10000; i++)
                fastList.remove(i);
        },"fastList delete");




    }

    public static void printRT(Runnable runnable,String name){
        long start = System.currentTimeMillis();
        runnable.run();
        log.info("{}:{}",name,String.valueOf(System.currentTimeMillis() - start));
    }
}
